<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tìm kiếm nâng cao</title>
</head>

<body>
<?php
				@session_start();
				if(isset($_GET["themgiohang"]))
				{
					$id=$_GET["themgiohang"];
					if(isset($_SESSION['giohang']) && is_array($_SESSION['giohang']))
					{
						$count= count($_SESSION['giohang']);
						$flag=false;
						for ($i = 0; $i < $count; $i++)
						{ 
						if($_SESSION['giohang'][$i]["id"] == $id){
							$_SESSION['giohang'][$i]["soluong"] +=1;
									$flag=true;
									break;
							}
							}
						if($flag == false)
						{$_SESSION['giohang'][$count]["id"]=$id;
							$_SESSION['giohang'][$count]["soluong"]=1;
							}
						}else {
							$_SESSION['giohang']=array();
							$_SESSION['giohang'][0]["id"]=$id;
							$_SESSION['giohang'][0]["soluong"]=1;
							echo "<script> comfirm('Please enter some text!');</script>";

							}
						header("Location: cts.php?id=".$id."");
						$sl = $_SESSION['giohang'][0]["soluong"];
						echo "yyyyyyyyyy".$sl;
				}
	require ('admin/models/m_sach.php'); 
	require ('admin/models/m_index.php'); 
	require ('admin/models/sharefunction.php'); 
	include ('login.php');
	dbconnect();
	$cosanpham=0;
	$menu = Menu(0);
	$nxb=getbyall_nxb();
	if(isset($_GET['tensach']))
	$tensach = $_GET['tensach'];
		if(isset($_GET['chude']))
	$chude = $_GET['chude'];
		if(isset($_GET['nhaxb']))
	$nhaxb =  $_GET['nhaxb'];
		if(isset($_GET['nxb']))
	$namxb = $_GET['nxb'];
		if(isset($_GET['db']))
	$dangbia = $_GET['db'];
	
	
	if(isset($_GET['ok']))
	{
	if($chude !=0) $where = "ID_Chu_de=".$chude.""; else $where =NULL ;
	if ($nhaxb !=0) $where ? $where.= " and ID_Nha_xuat_ban=".$nhaxb."" : $where.= "ID_Nha_xuat_ban=".$nhaxb."";
	if ($dangbia !=NULL) $where ? $where.= " and Dang_bia=N'".$dangbia."'" : $where.= "Dang_bia=N'".$dangbia."'";
	if ($namxb !=0) $where ? $where.= " and Nam_xuat_ban=".$namxb."" : $where.= "Nam_xuat_ban=".$namxb."";
	
	
	echo $where;
	if($where ==NULL) {
		 $result = search_sachbyall1($where,$tensach);
		$countsach = count_sachbyall1($where,$tensach);
		if($countsach>0){$cosanpham=2;}else {$cosanpham=1;}
		}else {
    $result = search_sachbyall($where,$tensach);
	$countsach = count_sachbyall($where,$tensach);
	if($countsach>0){$cosanpham=2;}else {$cosanpham=1;}}
	}
	require ('v_timkiemnc.php'); 
	
?>
</body>
</html>